#include "StdAfx.h"
#include "NetManagerCL.h"

#include "DBC2SProtocalCL.h"

NetManagerCL::NetManagerCL(void)
:m_pIce(NULL)
,m_pAdapter(NULL)
,m_pLogin(NULL)
{
}

NetManagerCL::~NetManagerCL(void)
{
}

void NetManagerCL::Initial() 
{
	m_pIce = Ice::initialize() ;

	m_pAdapter = m_pIce->createObjectAdapterWithEndpoints("DBProtocal" , "tcp -p 10000") ;

	m_pLogin = new DBLoginCL() ;
	m_pAdapter->add(m_pLogin , m_pIce->stringToIdentity("DBProtocalLogin")) ;

	m_pAdapter->activate() ;
}

void NetManagerCL::Destroy() 
{
	m_pLogin = NULL ;

	m_pAdapter = NULL ;

    if(m_pIce != NULL)
	{
		m_pIce->destroy() ;
		m_pIce = NULL ;
	}
}

Ice::ObjectAdapterPtr  NetManagerCL::GetAdapter()
{
    return m_pAdapter ;
}